import React from 'react';
import { inject, observer } from 'mobx-react';

import { WeaLocaleProvider, WeaAuth } from 'ecCom';

import { Text } from '../util/text';
import * as Apis from '../../apis/info';
const text = new Text();
const getLabel = WeaLocaleProvider.getLabel;

@observer
class ShareDialog extends React.Component {
    constructor(){
        super();
        this.state={appDetachDisableAll:false}
    }
    componentDidMount(){
        console.log();
        Apis.getAppDetachDisableAll().then((data)=>{
            if (data.api_status == '1') {
                this.setState({appDetachDisableAll:data.appDetachDisableAll})   
			} else {
				message.error(data.api_errormsg);
			}
        })
    }
    addShare = (v) => {
        const {store} = this.props;
        store.addShare(v);
        store.setState({ shareVisible: false });
    }

    onCancel = () => {
        const {store} = this.props;
        store.setState({ shareVisible: false });
    }

    render() {
        const {store:{status,setState},pathId } = this.props;
        const {appDetachDisableAll} = this.state;
        const {shareVisible} = status;
        let conditons = [
            {
                "colSpan": 2,
                "conditionType": "SELECT",
                "domkey": [
                    "sharetype"
                ],
                "fieldcol": 18,
                "isQuickSearch": false,
                "label": getLabel(21956, "对象类型"),
                "labelcol": 6,
                "options": [
                    {
                        "key": "1",
                        "selected": true,
                        "showname": getLabel(179, "人力资源")
                    }, {
                        "key": "2",
                        "selected": false,
                        "showname": getLabel(141, "分部")
                    }, {
                        "key": "3",
                        "selected": false,
                        "showname": getLabel(124, "部门")
                    }, {
                        "key": "4",
                        "selected": false,
                        "showname": getLabel(122, "角色")
                    }, {
                        "key": "5",
                        "selected": false,
                        "showname": getLabel(1340, "所有人")
                    }, {
                        "key": "6",
                        "selected": false,
                        "showname": getLabel(6086, "岗位")
                    }, {
                        "key": "7",
                        "selected": false,
                        "showname": getLabel(390870, "上报单位")
                    }
                ],
                "viewAttr": 2
            }, {
                "1": [[
                    {
                        "browserConditionParam": {
                            "completeParams": {},
                            "conditionDataParams": {},
                            "dataParams": {},
                            "destDataParams": {},
                            "hasAddBtn": false,
                            "hasAdvanceSerach": true,
                            "idSeparator": ",",
                            "isAutoComplete": 1,
                            "isDetail": 0,
                            "isMultCheckbox": false,
                            "isSingle": false,
                            "pageSize": 10,
                            "quickSearchName": "",
                            "type": "17",
                            "viewAttr": 3
                        },
                        "colSpan": 2,
                        "conditionType": "BROWSER",
                        "domkey": [
                            "relatedid"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": getLabel(106, "对象"),
                        "labelcol": 6,
                        "viewAttr": 3
                    }
                ]
                ],
                "2": [[
                    {
                        "browserConditionParam": {
                            "completeParams": {},
                            "conditionDataParams": {},
                            "dataParams": {},
                            "destDataParams": {},
                            "hasAddBtn": false,
                            "hasAdvanceSerach": true,
                            "idSeparator": ",",
                            "isAutoComplete": 1,
                            "isDetail": 0,
                            "isMultCheckbox": false,
                            "isSingle": false,
                            "pageSize": 10,
                            "quickSearchName": "",
                            "type": "194",
                            "viewAttr": 3
                        },
                        "colSpan": 2,
                        "conditionType": "BROWSER",
                        "domkey": [
                            "relatedid"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": getLabel(106, "对象"),
                        "labelcol": 6,
                        "value": 3,
                        "viewAttr": 2
                    }
                ], [
                    {
                        "colSpan": 2,
                        "conditionType": "INPUT_INTERVAL",
                        "domkey": [
                            "seclevel",
                            "seclevel2"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": getLabel(683, "安全级别"),
                        "labelcol": 6,
                        "value": [
                            0,
                            ''
                        ],
                        "viewAttr": 3,
                        "needDefaultValue":false
                    }
                ]
                ],
                "3": [[
                    {
                        "browserConditionParam": {
                            "completeParams": {},
                            "conditionDataParams": {},
                            "dataParams": {},
                            "destDataParams": {},
                            "hasAddBtn": false,
                            "hasAdvanceSerach": true,
                            "idSeparator": ",",
                            "isAutoComplete": 1,
                            "isDetail": 0,
                            "isMultCheckbox": false,
                            "isSingle": false,
                            "pageSize": 10,
                            "quickSearchName": "",
                            "type": "57",
                            "viewAttr": 3
                        },
                        "colSpan": 2,
                        "conditionType": "BROWSER",
                        "domkey": [
                            "relatedid"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": getLabel(106, "对象"),
                        "labelcol": 6,
                        "viewAttr": 3
                    }
                ], [
                    {
                        "colSpan": 2,
                        "conditionType": "INPUT_INTERVAL",
                        "domkey": [
                            "seclevel",
                            "seclevel2"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": getLabel(683, "安全级别"),
                        "labelcol": 6,
                        "value": [
                            0,
                            ''
                        ],
                        "viewAttr": 3,
                        "needDefaultValue":false
                    }
                ]
                ],
                "5": [
                    [
                        {
                            "colSpan": 2,
                            "conditionType": "INPUT_INTERVAL",
                            "domkey": [
                                "seclevel",
                                "seclevel2"
                            ],
                            "fieldcol": 18,
                            "isQuickSearch": false,
                            "label": getLabel(683, "安全级别"),
                            "labelcol": 6,
                            "value": [
                                0,
                                ''
                            ],
                            "viewAttr": 3,
                            "needDefaultValue":false
                        }
                    ]
                ],
                "4": [[
                    {
                        "browserConditionParam": {
                            "completeParams": {},
                            "conditionDataParams": {},
                            "dataParams": {},
                            "destDataParams": {},
                            "hasAddBtn": false,
                            "hasAdvanceSerach": true,
                            "idSeparator": ",",
                            "isAutoComplete": 1,
                            "isDetail": 0,
                            "isMultCheckbox": false,
                            "isSingle": false,
                            "pageSize": 10,
                            "quickSearchName": "",
                            "type": "65",
                            "viewAttr": 3
                        },
                        "colSpan": 2,
                        "conditionType": "BROWSER",
                        "domkey": [
                            "relatedid"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": getLabel(106, "对象"),
                        "labelcol": 6,
                        "viewAttr": 3
                    }, {
                        "colSpan": 2,
                        "conditionType": "SELECT",
                        "domkey": [
                            "rolelevel"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": getLabel(139, "级别"),
                        "labelcol": 6,
                        "options": [
                            {
                                "key": "0",
                                "selected": true,
                                "showname": getLabel(124, "部门")
                            }, {
                                "key": "1",
                                "selected": false,
                                "showname": getLabel(141, "分部")
                            }, {
                                "key": "2",
                                "selected": false,
                                "showname": getLabel(140, "总部")
                            }
                        ],
                        "viewAttr": 2
                    }
                ], [
                    {
                        "colSpan": 2,
                        "conditionType": "INPUT_INTERVAL",
                        "domkey": [
                            "seclevel",
                            "seclevel2"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": getLabel(683, "安全级别"),
                        "labelcol": 6,
                        "value": [
                            0,
                            ''
                        ],
                        "viewAttr": 3,
                        "needDefaultValue":false
                    }
                ]
                ],
                "6": [[
                    {
                        "browserConditionParam": {
                            "completeParams": {},
                            "conditionDataParams": {},
                            "dataParams": {},
                            "destDataParams": {},
                            "hasAddBtn": false,
                            "hasAdvanceSerach": true,
                            "idSeparator": ",",
                            "isAutoComplete": 1,
                            "isDetail": 0,
                            "isMultCheckbox": false,
                            "isSingle": false,
                            "pageSize": 10,
                            "quickSearchName": "",
                            "type": "278",
                            "viewAttr": 3
                        },
                        "colSpan": 2,
                        "conditionType": "BROWSER",
                        "domkey": [
                            "relatedid"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": getLabel(106, "对象"),
                        "labelcol": 6,
                        "viewAttr": 3
                    }
                ], [
                    {
                        "colSpan": 2,
                        "conditionType": "SELECT_LINKAGE",
                        "domkey": [
                            "joblevel"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": getLabel(28169, "岗位级别"),
                        "labelcol": 6,
                        "options": [
                            {
                                "key": "2",
                                "selected": true,
                                "showname": getLabel(140, "总部")
                            }, {
                                "key": "1",
                                "selected": false,
                                "showname": getLabel(19437, "指定分部")
                            }, {
                                "key": "0",
                                "selected": false,
                                "showname": getLabel(19438, "指定部门")
                            }
                        ],
                        "selectLinkageDatas": {
                            "1": {
                                "browserConditionParam": {
                                    "completeParams": {},
                                    "conditionDataParams": {},
                                    "dataParams": {},
                                    "destDataParams": {},
                                    "hasAddBtn": false,
                                    "hasAdvanceSerach": true,
                                    "idSeparator": ",",
                                    "isAutoComplete": 1,
                                    "isDetail": 0,
                                    "isMultCheckbox": false,
                                    "isSingle": false,
                                    "pageSize": 10,
                                    "quickSearchName": "",
                                    "type": "194",
                                    "viewAttr": 3
                                },
                                "colSpan": 2,
                                "conditionType": "BROWSER",
                                "domkey": [
                                    "jobleveltextsubcompany"
                                ],
                                "fieldcol": 18,
                                "isQuickSearch": false,
                                "label": "",
                                "labelcol": 6,
                                "viewAttr": 3
                            },
                            "0": {
                                "browserConditionParam": {
                                    "completeParams": {},
                                    "conditionDataParams": {},
                                    "dataParams": {},
                                    "destDataParams": {},
                                    "hasAddBtn": false,
                                    "hasAdvanceSerach": true,
                                    "idSeparator": ",",
                                    "isAutoComplete": 1,
                                    "isDetail": 0,
                                    "isMultCheckbox": false,
                                    "isSingle": false,
                                    "pageSize": 10,
                                    "quickSearchName": "",
                                    "type": "57",
                                    "viewAttr": 3
                                },
                                "colSpan": 2,
                                "conditionType": "BROWSER",
                                "domkey": [
                                    "jobleveltextdepartment"
                                ],
                                "fieldcol": 18,
                                "isQuickSearch": false,
                                "label": "",
                                "labelcol": 6,
                                "viewAttr": 3
                            }
                        },
                        "viewAttr": 2
                    }
                ]
                ],
                "7": [
                    [
                        {
                            "browserConditionParam": {
                                "completeParams": {},
                                "conditionDataParams": {},
                                "dataParams": {id:pathId},
                                "completeParams":{id:pathId},
                                "destDataParams": {},
                                "hasAddBtn": false,
                                "hasAdvanceSerach": true,
                                "idSeparator": ",",
                                "isAutoComplete": 1,
                                "isDetail": 0,
                                "isMultCheckbox": false,
                                "isSingle": false,
                                "pageSize": 10,
                                "quickSearchName": "",
                                "type": "infoReportOrg",
                                "viewAttr": 3
                            },
                            "colSpan": 2,
                            "conditionType": "BROWSER",
                            "domkey": [
                                "relatedid"
                            ],
                            "fieldcol": 18,
                            "isQuickSearch": false,
                            "label": getLabel(106, "对象"),
                            "labelcol": 6,
                            "viewAttr": 3
                        }
                    ]
                ],
            }
        ];
        appDetachDisableAll === true ? conditons[0].options.splice(4,1) : conditons ;
        return (
            <div >
                <WeaAuth ecId={`${this && this.props && this.props.ecId || ''}_WeaAuth@oor6bz`}
                    icon="icon-coms-government"
                    iconBgcolor='#f14a2d'
                    visible={shareVisible}
                    conditions={conditons}
                    title='添加共享'
                    onOk={this.addShare}
                    onCancel={this.onCancel}
                />
            </div>
        )
    }
    

}
export { ShareDialog };